#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    bool checkPossibility(vector<int>& nums) {
        int changeNum = 0;
        for(int i=0;i<nums.size()-1;++i){
            if(nums[i]<=nums[i+1]){
                continue;
            }
            else{
                //此处得尤为注意
                if(i-1>=0&&nums[i-1]<=nums[i+1]){
                    nums[i] = nums[i+1];
                }
                else if(i-1>=0&&nums[i-1]>nums[i+1]){
                    nums[i+1] = nums[i];
                }
                else {
                    nums[i] = nums[i+1];
                }
                ++changeNum;
            }
            if(changeNum>=2){
                return false;
            }
        }
        return true;
    }
};


int main(){
    Solution S;
    vector<int> nums = {3,4,2,3};
    cout<<S.checkPossibility(nums)<<endl;
}